﻿Namespace Cues.Converters
	Public Class TransportCueActionToSelectionConverter
		Implements IValueConverter

		Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.Convert
			Try
				If CType(value, Cues.TransportActions) = Cues.TransportActions.StopAllActiveCues Then
					Return 1
				ElseIf CType(value, Cues.TransportActions) = Cues.TransportActions.StartCue Then
					Return 2
				ElseIf CType(value, Cues.TransportActions) = Cues.TransportActions.BumpCueStatus Then
					Return 3
				ElseIf CType(value, Cues.TransportActions) = Cues.TransportActions.AutoPan Then
					Return 4
				ElseIf CType(value, Cues.TransportActions) = Cues.TransportActions.AutoFade Then
					Return 5
				Else
					Return 0
				End If
			Catch
				Return 0
			End Try
		End Function

		Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
			Try
				If CInt(value) = 1 Then
					Return Cues.TransportActions.StopAllActiveCues
				ElseIf CInt(value) = 0 Then
					Return Cues.TransportActions.StopSpecificCue
				ElseIf CInt(value) = 2 Then
					Return Cues.TransportActions.StartCue
				ElseIf CInt(value) = 3 Then
					Return Cues.TransportActions.BumpCueStatus
				ElseIf CInt(value) = 4 Then
					Return Cues.TransportActions.AutoPan
				ElseIf CInt(value) = 5 Then
					Return Cues.TransportActions.AutoFade
				Else
					Return Cues.TransportActions.StopSpecificCue
				End If
			Catch ex As Exception
				Return Cues.TransportActions.StopSpecificCue
			End Try
		End Function
	End Class
End Namespace